let countV2 = 0;
function getGreatestCommonDivisorV2(a, b) {
    countV2++;
    const big = a > b ? a : b;
    const small = a < b ? a : b;
    if (big % small === 0) {
        return small;
    }
    return getGreatestCommonDivisorV2(big % small, small);
}
console.log(getGreatestCommonDivisorV2(963, 1875));
console.log(countV2);

let countV3 = 0;
function getGreatestCommonDivisorV3(a, b) {
    countV3++;
    if (a === b) {
        return a;
    }
    const big = a > b ? a : b;
    const small = a < b ? a : b;
    return getGreatestCommonDivisorV3(big - small, small);
}
console.log(getGreatestCommonDivisorV3(963, 1875));
console.log(countV3);

let countV4 = 0;
function gcd(a, b) {
    countV4++;
    if (a === b) return a;
    // 两偶
    if ((a & 1) === 0 && (b & 1) === 0) {
        return gcd(a >> 1, b >> 1) << 1;
    }
    // a偶，b奇
    else if ((a & 1) === 0 && (b & 1) !== 0) {
        return gcd(a >> 1, b);
    }
    // a奇，b偶
    else if ((a & 1) !== 0 && (b & 1) === 0) {
        return gcd(a, b >> 1);
    }
    // 两奇
    else {
        const big = a > b ? a : b;
        const small = a < b ? a : b;
        return gcd(big - small, small);
    }
}
console.log(gcd(963, 1875));
console.log(countV4);